﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HECore.NLogWebApi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class HomeController : ControllerBase
    {
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
            _logger.LogDebug(1, "NLog injected into HomeController");
        }

        [HttpGet("LogInformation")]
        public string LogInformation()
        {
            _logger.LogInformation("LogInformation");
            return "ok";
        }

        [HttpGet("LogError")]
        public string LogError()
        {
            throw new Exception("error");
        }

        [HttpPost("LogRequest")]
        [RequestTrace]
        public string LogRequest([FromBody] List<string> input)
        {
            return "ok";
        }
    }
}
